﻿<?php
/**
 * @package WordPress
 * @subpackage Classic_Theme
 */
 ?>
<!--            .............................................Comments area start.......................................  -->
<h5 class="sectionHeader"><?php
	if ( post_password_required() ){
		echo "<p>Enter your password to view comments.</p>";
		return;
	} 
	//comments_number(__('No Comments'), __('1 Comment'), __('% Comments'));
	//comments_number('no responses','one response','% responses');
	echo "External feedacks <br/>";
?></h5>

<!--            .............................................Output comments.......................................  -->
<?php if ( have_comments() ) : ?>
<ul id="commentlist" class="commentlist">


<?php $index=0; 
foreach ($comments as $comment) : ++$index; ?>
	<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">	
	  <?php //echo get_avatar( $comment, 32 ); ?> 
          <div class="commentText"><?php echo convertNewlineToBRcode(get_comment_text()) ?></div> 
            
		<small style="border-bottom: 1px dotted #DDDDDD">
		<?php comment_type(_x('Comment', 'noun'), __('Trackback'), __('Pingback'));  _e(' by ');  comment_author_link() ?>
			&#8212;
		
<?php comment_date(); echo ' at '; comment_time();  ?> 
                <a href="#comment-<?php comment_ID() ?>" onclick='return setCommentBoxText(<?PHP echo $index. ',"';comment_author();?>");'> reply</a>
				<?php edit_comment_link(__("Edit This"), ' || '); ?>
		</small>          
	</li>
        <div class="clear"></div>

<?php endforeach; ?>
<script type="text/javascript">
function setCommentBoxText(commentID, commentAuthorLink){

	var $comment=$("#comment");
	$("html").scrollTop( $comment.position().top);
	$comment.val( "@"+commentAuthorLink+": " ).select();
	//$comment.val( "@"+commentAuthorLink+" (#comment-"+commentID+ "): " ).select();
	return false;
}
</script>
</ul>
<?php endif;?>

<!--            .............................................Comment form.......................................  -->
<?php
    if ( !comments_open() ) :
        echo '<h2 class="leaveResponse">Sorry comments are closed now for this post!</h2>';
        return;
        endif;
?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post"
      class="commentform" id="commentform" onsubmit="" method="post" >

<h2 class="leaveResponse"><?php _e('Leave a response!'); ?></h2>

<p class="commentFormLoggedInUser">
    <small>Please be on topic. Thanks for your comment :-)</small>
</p>

<div>
<!--
<p class="userLoginOut">
<?php 
if( is_user_logged_in() && false ) { 
		//echo get_avatar($post->ID,64);
		echo get_avatar(rand()."@gmail.com",64);?>
		<a href="<?php echo wp_logout_url(get_permalink()); ?>" >Logout</a> <?php
}
else {
	echo  get_avatar("abcdefgh".  rand(4, 1234) . "@gmail.com",48)."<br/>";
	echo wp_loginout(get_permalink()); 
} 
?>
</p>
-->
</div>

<?php
$isUserLoggedIn=is_user_logged_in();

if( !$isUserLoggedIn){?>
	<input type="hidden" name="comment_post_ID" value="<?PHP echo get_the_ID(); ?>" />
	
	<p class="inputCommentForm"><input tabindex="1" type="text" name="author" id="author" value="" size="22" tabindex="1" />
    <label for="author"><strong>⇦⇦ Name </strong><small><?php if ($req) _e('(required)'); ?></small></label></p>

	<p class="inputCommentForm"><input type="text" tabindex="2" name="email" id="email" value="" size="22" tabindex="2" />
	<label for="email"><strong>⇦ Email </strong><small><?php _e('(will not be published) (required)'); ?></small></label></p>

	<p class="inputCommentForm"><input type="text" name="url" tabindex="3" id="url" value="" size="22" tabindex="3" />
	<label for="url"><strong>⇦⇦ Website </strong><small><?php _e('(optional)'); ?></small></label></p>
	
	<p><strong>Your Comment:</strong><small><?php _e(' (will be published after moderator approval)'); ?></small></p>
	
<?PHP } else { ?>
	<input type="hidden" name="comment_post_ID" value="<?PHP echo get_the_ID(); ?>" />
	<input type="hidden" name="author" value="<?PHP the_author_meta( 'display_name' ); ?>" />
	<input type="hidden" name="email" value="<?PHP the_author_meta( 'email' ); ?>" />
	<input type="hidden" name="url" value="<?PHP bloginfo("siteurl"); echo "/?author=". get_the_author_meta( 'ID' ); ?>" />
<?PHP } ?>
<div class="inputCommentForm">
    <textarea name="comment" id="comment" value="" cols="70" rows="10" tabindex="4"></textarea>
</div>
<!-- end of input form elements (except submit button ) -->

<div class="clear"></div>
<input name="submit" type="submit" id="submit" tabindex="5" value="<?php esc_attr_e('Submit Comment'); ?>" />
or <a href="<?PHP bloginfo('siteurl'); echo "/wp-trackback.php?p=$post->ID"; ?>">trackback</a> from your own site.

<!-- You can also subscribe to these comments via <a href="<?php post_comments_feed_link(); ?>">RSS</a> -->

</form>